 
export default class Opengl01{
 
    canvas:HTMLCanvasElement ;
    gl:WebGLRenderingContext ;
    vertexData:Array<number>;
    buffer:WebGLBuffer;

    constructor(){  
        console.log('opengl01');
        this.createWebGl();
    }

    createWebGl(){
        this.canvas=document.querySelector('canvas')
        this.gl=this.canvas.getContext('webgl');
        if(!this.gl){
            throw new Error("WebGl not supported");
        } 
    }

    createTriangle(){ 
       this.vertexData =[
            0,1,0,
            1,-1,0,
            -1,-1,0
        ];

       this.buffer= this.gl.createBuffer();
       this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.buffer);
       this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.vertexData),this.gl.STATIC_DRAW);
       
    }

}